﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml; //必须引入System.Xml命名空间
using System.Xml.Linq;

namespace WEEK10_LAB01
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string filePath = Server.MapPath("汽车.xml"); //得到与本页面在同一个文件夹下的“汽车.xml”在服务器硬盘上的绝对路径

            try
            {
                XmlReader reader = XmlReader.Create(filePath); //根据指定文件路径创建一个XmlReader对象
                while (reader.Read()) //不断读取节点直到文件末尾
                {
                    Response.Write("<p>【NodeType:" + reader.NodeType + "】,【NodeName:" + reader.Name + "】,【NodeValue:" +
                                   reader.Value + "】</p>");
                    //输出每个节点的节点类型、节点名称与节点值
                }
                reader.Close(); //关闭XmlReader
            }
            catch (Exception exception)
            {
                Response.Write(exception.Message); //输出异常信息
            }
        }
    }
}